import React from "react";
import { Badge, TabBar } from "antd-mobile";
import {
  AppOutline,
  MessageOutline,
  MessageFill,
  UnorderedListOutline,
  UserOutline,
} from "antd-mobile-icons";
import styles from "../css/tabbar.module.css";
import { useLocation, useNavigate } from "react-router-dom";
function Index() {
  const tabs = [
    {
      key: "/home",
      title: "首页",
      icon: <AppOutline />,
    },
    {
      key: "/chat",
      title: "待办",
      icon: <UnorderedListOutline />,
    },
    {
      key: "/order-list",
      title: "消息",
      icon: <MessageOutline />,
    },
    {
      key: "/me",
      title: "我的",
      icon: <UserOutline />,
    },
  ];
  let nav = useNavigate();
  const change = (key) => {
    nav(key);
  };
  let loca = useLocation();
  return (
    <div className={styles.box1}>
      <TabBar
        activeKey={loca.pathname === "/" ? "/home" : loca.pathname}
        onChange={change}
      >
        {tabs.map((item) => (
          <TabBar.Item key={item.key} icon={item.icon} title={item.title} />
        ))}
      </TabBar>
    </div>
  );
}

export default Index;
